package com.lgc.demo.ReflectTest.test2;

import java.lang.reflect.Method;

public class Program {
    public static void main(String[] args) {
        A a =new A();
        Class c = a.getClass();
        try {
            Method method=c.getMethod("add",new Class[]{int.class,int.class});
            //也可以 Method method=c.getMethod("add",int.class,int.class);
            //方法的反射操作
            method.invoke(a,10,10);
        }catch (Exception e){
            e.printStackTrace();
        }
    }
}
